VERSION 5.00
Begin VB.UserControl VSplitPane 
   Appearance      =   0  'Flat
   BackColor       =   &H00E0E0E0&
   ClientHeight    =   3600
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   4800
   ControlContainer=   -1  'True
   ScaleHeight     =   3600
   ScaleWidth      =   4800
   ToolboxBitmap   =   "VSplitPane.ctx":0000
   Begin VB.PictureBox bar 
      BackColor       =   &H00E2A981&
      BorderStyle     =   0  'None
      Height          =   75
      Left            =   540
      MouseIcon       =   "VSplitPane.ctx":00FA
      MousePointer    =   99  'Custom
      ScaleHeight     =   75
      ScaleWidth      =   1875
      TabIndex        =   1
      Top             =   1620
      Width           =   1875
   End
   Begin VB.PictureBox shadow 
      BackColor       =   &H00808080&
      BorderStyle     =   0  'None
      Height          =   75
      Left            =   2640
      ScaleHeight     =   75
      ScaleWidth      =   1875
      TabIndex        =   0
      Top             =   1620
      Visible         =   0   'False
      Width           =   1875
   End
End
Attribute VB_Name = "VSplitPane"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Const dBarHeight    As Single = 75
Const dTopMin       As Single = 1800
Const dBottomMin    As Single = 1800

Dim mBarHeight      As Single
Dim mTopMin         As Single
Dim mBottomMin      As Single
Dim mSplitterPos    As Single

Dim TopPane()       As Object
Dim BottomPane()    As Object
Dim topCount        As Long
Dim bottomCount     As Long

Dim TopVisible      As Boolean
Dim BottomVisible   As Boolean

Dim cy As Single

Public Sub SetTop(ParamArray ctls())
    Dim i As Long

    ReDim TopPane(0 To UBound(ctls)) As Object
    For i = 0 To UBound(ctls)
        Set TopPane(i) = ctls(i)
    Next
    
    topCount = i
    TopPane(0).ZOrder 1

    shadow.ZOrder 0
    DoLayout
End Sub

Public Sub SetBottom(ParamArray ctls())
    Dim i As Long
    
    ReDim BottomPane(0 To UBound(ctls)) As Object
    For i = 0 To UBound(ctls)
        Set BottomPane(i) = ctls(i)
        
    Next
    
    bottomCount = i
    BottomPane(0).ZOrder 1
    
    shadow.ZOrder 0
    DoLayout
End Sub

Public Sub HideTop()

End Sub

Public Sub HideBottom()

End Sub

Private Sub bar_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    shadow.Top = bar.Top
    shadow.Visible = True
    cy = bar.Top
End Sub

Private Sub bar_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If shadow.Visible Then
        If cy + y <= mTopMin Then
            shadow.Move 0, mTopMin
        ElseIf cy + y >= ScaleHeight - bar.Height - mBottomMin Then
            shadow.Move 0, ScaleHeight - bar.Height - mBottomMin
        Else
            shadow.Move 0, cy + y
        End If
    End If
End Sub

Private Sub bar_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    bar.Top = shadow.Top
    mSplitterPos = bar.Top
    shadow.Visible = False
    DoLayout
End Sub

Private Sub UserControl_InitProperties()
    mBarHeight = dBarHeight
    mTopMin = dTopMin
    mBottomMin = dBottomMin
    mSplitterPos = mTopMin
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    With PropBag
        mBarHeight = .ReadProperty("BarHeight", dBarHeight)
        mTopMin = .ReadProperty("TopMin", dTopMin)
        mBottomMin = .ReadProperty("BottomMin", dBottomMin)
        bar.BackColor() = .ReadProperty("BarColor", bar.BackColor)
        UserControl.BackColor() = .ReadProperty("BackColor", UserControl.BackColor)
        mSplitterPos = .ReadProperty("SplitterPos", bar.Top)
    End With
    UserControl_Resize
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    With PropBag
        .WriteProperty "TopMin", mTopMin, dTopMin
        .WriteProperty "BottomMin", mBottomMin, dBottomMin
        .WriteProperty "BarHeight", mBarHeight, dBarHeight
        .WriteProperty "BarColor", bar.BackColor()
        .WriteProperty "BackColor", UserControl.BackColor()
        .WriteProperty "SplitterPos", mSplitterPos
    End With
End Sub

Private Sub UserControl_Resize()
    bar.Move 0, mSplitterPos, ScaleWidth, mBarHeight
    shadow.Move 0, bar.Top, ScaleWidth, mBarHeight

    DoLayout
End Sub

Public Property Get SplitterPos() As Single
    SplitterPos = mSplitterPos
End Property

Public Property Let SplitterPos(ByVal Value As Single)
    mSplitterPos = Value
    PropertyChanged "SplitterPos"
    UserControl_Resize
End Property

Public Property Get TopMin() As Single
    TopMin = mTopMin
End Property

Public Property Let TopMin(ByVal Value As Single)
    mTopMin = Value
    UserControl_Resize
    PropertyChanged "TopMin"
End Property

Public Property Get BarHeight() As Single
    BarHeight = shadow.Height
End Property

Public Property Let BarHeight(ByVal Value As Single)
    mBarHeight = Value
    UserControl_Resize
    PropertyChanged "BarHeight"
End Property

Public Property Get BottomMin() As Single
    BottomMin = mBottomMin
End Property

Public Property Let BottomMin(ByVal Value As Single)
    mBottomMin = Value
    DoLayout
    PropertyChanged "BottomMin"
End Property

Public Property Let BarColor(ByVal Value As OLE_COLOR)
    bar.BackColor = Value
End Property

Public Property Get BarColor() As OLE_COLOR
    BarColor = bar.BackColor
End Property

Public Property Get BackColor() As OLE_COLOR
    BackColor = UserControl.BackColor
End Property

Public Property Let BackColor(ByVal Value As OLE_COLOR)
    UserControl.BackColor = Value
End Property

Private Sub DoLayout()
On Error Resume Next
    Dim i As Long
    
    If topCount = 0 Or bottomCount = 0 Then Exit Sub
    
    If bar.Top <= mTopMin Then
        bar.Top = mTopMin
    End If
    If bar.Top >= ScaleHeight - mBottomMin - mBarHeight Then
        bar.Top = ScaleHeight - mBottomMin - mBarHeight
    End If
    
    For i = 0 To topCount - 1
        TopPane(i).Move 0, 0, ScaleWidth, bar.Top
    Next


    For i = 0 To bottomCount - 1
        BottomPane(i).Move 0, bar.Top + bar.Height, ScaleWidth, ScaleHeight - bar.Top - bar.Height
    Next
End Sub



